﻿
namespace SIR.Web
{
	/// <summary>
	/// A response object to send back after a request
	/// </summary>
	/// <typeparam name="T">The type of the condents</typeparam>
	public class Response<T>
	{
		/// <summary>
		/// Creates a new response with the specified values
		/// </summary>
		/// <param name="successful">Whether or not the performed action was successful</param>
		/// <param name="content">The contents of the response</param>
		/// <param name="message">The message attached to the response</param>
		/// <returns>A new respinse object with the passed values</returns>
		public static Response<T> CreateResponse(bool successful, T content,
			string message = null)
		{
			return new Response<T>()
			{
				Successful = successful,
				Content = content,
				Message = message ?? string.Empty
			};
		}

		/// <summary>
		/// Response must be created through the CreateResponse method
		/// </summary>
		private Response() { }
		/// <summary>
		/// Gets whether or not the performed action was successful
		/// </summary>
		public bool Successful { get; private set; }
		/// <summary>
		/// Gets the message attached to the response
		/// </summary>
		public string Message { get; private set; }
		/// <summary>
		/// Gets the contents of the response
		/// </summary>
		public T Content { get; private set; }
	}
}